package cn.xopencode.securityservice.service.suggest.impl;

import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.securityservice.convert.suggest.SuggestConvert;
import cn.xopencode.securityservice.dal.mysql.dataobject.suggest.SuggestDO;
import cn.xopencode.securityservice.dal.mysql.mapper.suggest.SuggestMapper;
import cn.xopencode.securityservice.rpc.suggest.dto.SuggestCreateReqDTO;
import cn.xopencode.securityservice.rpc.suggest.dto.SuggestPageReqDTO;
import cn.xopencode.securityservice.rpc.suggest.dto.SuggestRespDTO;
import cn.xopencode.securityservice.service.suggest.SuggestService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * 安全活动与技能比武情况 Service 实现
 */
@Service
public class SuggestServiceImpl implements SuggestService {
    @Autowired
    private SuggestMapper suggestMapper;



    public Boolean createSuggest(SuggestCreateReqDTO createDTO) {
        int isSuccess = suggestMapper.insert(SuggestConvert.INSTANCE.convert(createDTO));
        if(isSuccess>0){
            return true;
        }
        return false;
    }
    /**
     * 安全活动与技能比武情况分页
     *
     * @param pageReqDTO 安全活动与技能比武情况分页查询
     * @return 安全活动与技能比武情况分页结果
     */
    @Override
    public PageResult<SuggestRespDTO> pageSuggest(SuggestPageReqDTO pageReqDTO) {
        IPage<SuggestDO> userDOPage = suggestMapper.selectPage(pageReqDTO);
                return SuggestConvert.INSTANCE.convertPage(userDOPage);
    }

    /**
     * 获得安全活动与技能比武情况
     *
     * @param suggestId 安全活动与技能比武情况编号
     * @return 安全活动与技能比武情况
     */
    @Override
    public SuggestRespDTO getSuggest(String suggestId) {
        SuggestDO suggestDO = suggestMapper.selectById(suggestId);
        return SuggestConvert.INSTANCE.convert(suggestDO);
    }
}

